package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    public void work(BookList bookList){
        System.out.println("归还图书");
        Scanner scanner = new Scanner(System.in); //从键盘输入
        System.out.println("请输入书名：");
        String name = scanner.nextLine();  //输入一个字符串
        int currentSize = bookList.getUsedSize();  //数目

        //如果有这本书 就不能添加了
        for (int i = 0; i < currentSize; i++) {
            Book book1 = bookList.getBooks(i);
            if(book1.getName().equals(name)) {
                book1.setBorrowed(false);  //如果这本书名与归还的一样，就归还成功
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("没有你要归还的图书！");

    }
}
